#include "threadpool.h"
#include <iostream>

int func(int a, int b)
{
    return a + b;
}

int main()
{
    ThreadPool pool;
    pool.start();

    std::future<int> res1 = pool.submitTask([](int a, int b) -> int
                                           {
        int sum=0;
        for(int i=a;i<=b;i++)
        sum+=i;
        std::this_thread::sleep_for(std::chrono::seconds(5));
        return sum; }, 1, 10);
    std::future<int> res2 = pool.submitTask([](int a, int b) -> int
                                           {
        int sum=0;
        for(int i=a;i<=b;i++)
        sum+=i;
        std::this_thread::sleep_for(std::chrono::seconds(5));
        return sum; }, 1, 10);
    std::future<int> res3 = pool.submitTask([](int a, int b) -> int
                                           {
        int sum=0;
        for(int i=a;i<=b;i++)
        sum+=i;
        std::this_thread::sleep_for(std::chrono::seconds(5));
        return sum; }, 1, 10);
    std::future<int> res4 = pool.submitTask([](int a, int b) -> int
                                           {
        int sum=0;
        for(int i=a;i<=b;i++)
        sum+=i;
        std::this_thread::sleep_for(std::chrono::seconds(5));
        return sum; }, 1, 10);
    std::future<int> res5 = pool.submitTask([](int a, int b) -> int
                                           {
        int sum=0;
        for(int i=a;i<=b;i++)
        sum+=i;
        std::this_thread::sleep_for(std::chrono::seconds(5));
        return sum; }, 1, 10);
    std::cout << res1.get() << std::endl;
    std::cout << res2.get() << std::endl;
    std::cout << res3.get() << std::endl;
    std::cout << res4.get() << std::endl;
    std::cout << res5.get() << std::endl;
}
